package com.bao.Servlet;

import com.alibaba.fastjson.JSON;
import com.bao.Emtity.agency;
import com.bao.Service.AgencyService;
import com.bao.ServiceImpl.AgencyServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created by TangBaoshan on 2018/8/13.
 */
@WebServlet(name = "FindAgencyServlet")
public class FindAgencyServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out = response.getWriter();
        request.setCharacterEncoding("utf-8");
        AgencyService Ase = new AgencyServiceImpl();
        int id = Integer.parseInt(request.getParameter("uid"));
        agency a = new agency();
        a = Ase.FindNumAgency(id);
        String json = JSON.toJSONString(a);
        out.print(json);
        out.flush();
        out.close();
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
